package department;

import javax.jdo.annotations.*;
import java.util.*;
import course.Course;
import college.College;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Department {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key depId;
	
	@Persistent
	private String depName;
	
	@Persistent
	private College college;
	
	@Persistent(mappedBy = "CourseDepartment")
	@Element(dependent = "true") 
	private List <Course> course;
	
	public Department(String name,College col){
		this.depName = name;
		this.college = col;
		course = new ArrayList<Course>();
	}
	
	public Department(){
		this.depName = "NA";
	}
	
	public Long getId(){
		return depId.getId();
	}
	
	public String getName(){
		return depName;
	}
	
	public College getCol(){
		return college;
	}
	
	public void setName(String name){
		this.depName = name;
	}
	
	public List<Course> getAllCourse(){
		List<Course> temp = new ArrayList<Course>();
		for(Course c : course){
			temp.add(c);
		}
		return temp;
	}
	
	public void addCourse(String name,String sem,Department dep,Long teacher,String outline){
		course.add(new Course(name,sem,dep,teacher,outline));
	}
}
